#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<list>
#include<cstdlib>
#include<cmath>
#include<sstream>
#include<numeric>
#include<cstdio>
#include<cstring>
#include<stack>
#define PI acos(-1)
#define MP make_pair
#define PB push_back
#define VI vector <int>
#define PII pair <int,int>
#define LL long long
#define SET(v,i) memset(v, i, sizeof(v))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORD(i,a,b) for (int i = (a); i >= (b); i--)
#define FORN(i,a,b) for (int i = (a); i < (b); i++)
#define DOWN(i,a,b) for (int i = (a); i > (b); i--)
#define FIT(it,v) for (typeof(v.begin()) it = v.begin(); it != v.end(); it++)
#define FITD(it,v) for (typeof(v.rbegin()) it = v.rbegin(); it != v.rend(); it++)
using namespace std;
const int MAXN=200005;
vector<int>L[MAXN],R[MAXN];
int c[MAXN],a[MAXN],b[MAXN],ans[MAXN],l[MAXN],r[MAXN];
inline int lowbit(int k){return k&-k;}
void add(int x){
	for(;x<MAXN;x+=lowbit(x))c[x]++;
	}
int query(int x){
	int s=0;for(;x>0;x-=lowbit(x))s+=c[x];
	return s;
	}
int main(){
	int n,m,x,y;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)scanf("%I64d",&a[i]),b[a[i]]=i;
	for(int i=1;i<=m;i++){
		scanf("%d%d",&l[i],&r[i]);
		L[l[i]].push_back(i);
		R[r[i]].push_back(i);
		}
	
	for(int i=1;i<=n;i++){
		for(int j=0;j<L[i].size();j++)ans[L[i][j]]-=query(r[L[i][j]])-query(i-1);
		for(int j=a[i];j<=n;j+=a[i])add(b[j]);
		for(int j=0;j<R[i].size();j++)ans[R[i][j]]+=query(i)-query(l[R[i][j]]-1);
		}
	for(int i=1;i<=m;i++)printf("%d\n",ans[i]);	while(1);
    return 0;
    }
